package com.example.loggingservice.listener;

import com.example.loggingservice.dto.LogMessage;
import com.example.loggingservice.service.LoggingService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class LogListener {

    private final LoggingService loggingService;

    public static final String LOG_QUEUE = "user.log.queue";

    @RabbitListener(queues = LOG_QUEUE)
    public void receiveLogMessage(LogMessage logMessage) {
        loggingService.saveLog(logMessage);
    }
} 